****************************************************************************
**		Authors: 	Liran Harsgor
**		Purpose: 	Produce figure 1 in Kedar, Harsgor & Tuttnauer (JOP) 
**		input:		KHT_districtlevel.dta
*****************************************************************************

log using "figure 1.log", replace

use "KHT_districtlevel.dta", clear

/*legislatures <110 seats*/
graph hbar dm if dpr==1 & tsc<110, ///
over(district_c) over(cyear, sort(sr) label(labsize(vsmall) labcolor(gray)) gap(*4)) stack asyvars  ///
ylabel(0(100)650, labsize(vsmall)) ///
graphregion(fcolor(white) lcolor(white)) ///
legend(off) ytitle(" ")  intensity(0) lintensity(1000) ///
text(105 2 "4.21", place(e) size(vsmall)) text(86 10 "3.71", place(e) size(vsmall)) ///
text(95 18 "3.50", place(e) size(vsmall)) text(61 26 "3.31", place(e) size(vsmall)) ///
text(65 34 "2.75", place(e) size(vsmall)) text(65 42 "2.45", place(e) size(vsmall)) ///
text(70 50 "2.05", place(e) size(vsmall)) text(105 58 "1.78", place(e) size(vsmall)) ///
text(96 66 "1.57", place(e) size(vsmall)) text(45 74 "1.42", place(e) size(vsmall)) ///
text(107 82 "1.40", place(e) size(vsmall)) text(70 90 "1.17", place(e) size(vsmall)) ///
text(70 98 "1.00", place(e) size(vsmall))
graph save "dm_bars1n", replace

/*legislatures >=200 seats*/
graph hbar dm if dpr==1 & tsc>=200, ///
over(district_c) over(cyear, sort(sr) label(labsize(vsmall) labcolor(gray)) gap(*4)) stack asyvars  ///
ylabel(0(100)650, labsize(vsmall)) ///
graphregion(fcolor(white) lcolor(white)) ///
legend(off) ytitle(" ")  intensity(0) lintensity(1000) ///
text(205 2 "5.25", place(e) size(vsmall)) text(235 10 "4.90", place(e) size(vsmall)) ///
text(555 18 "3.62", place(e) size(vsmall)) text(518 26 "3.58", place(e) size(vsmall)) ///
text(295 34 "3.50", place(e) size(vsmall)) text(635 42 "2.75", place(e) size(vsmall)) ///
text(355 50 "2.72", place(e) size(vsmall)) text(205 58 "2.64", place(e) size(vsmall)) ///
text(245 66 "2.02", place(e) size(vsmall)) text(205 74 "1.98", place(e) size(vsmall)) ///
text(355 82 "1.92", place(e) size(vsmall)) text(565 90 "1.56", place(e) size(vsmall)) ///
text(465 98 "1.47", place(e) size(vsmall))
graph save "dm_bars3n", replace

graph combine "dm_bars1n" "dm_bars3n"  ///
, row(3) ysize(13) xsize(20) ///
imargin(zero) ///
graphregion(fcolor(white) lcolor(white)) 

graph save "figure 1", replace

log close
